package com.simen.sample;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.simen.marqueeview.VerticalMarqueeView;
import com.simen.marqueeview.MessageText;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends Activity {
    private static final String TAG = "MainActivity";
    VerticalMarqueeView verticalMarqueeView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        verticalMarqueeView = (VerticalMarqueeView) findViewById(R.id.marquee);

        List<MessageText> messages = new ArrayList<>();
        messages.add(new MessageText("今日大涨", "url1"));
        messages.add(new MessageText("hello,this is message", "url2"));
        messages.add(new MessageText("明日多云转晴,有微风", "url3"));
        messages.add(new MessageText("title4", "url4"));
        verticalMarqueeView.setMessages(messages);
        verticalMarqueeView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                VerticalMarqueeView view = (VerticalMarqueeView) v;
                MessageText message = view.getCurrentMessage();
                Log.d(TAG, "onClick: " + (message == null ? "空消息" : message.getValue()));
            }
        });

    }

    @Override
    protected void onStart() {
        super.onStart();
        verticalMarqueeView.resume(0);
    }

    @Override
    protected void onStop() {
        super.onStop();
        verticalMarqueeView.pause();
    }
}
